<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<!-- <p><span style="color: red;">我</span>爱中国<span style="color: red;">我</span></p> -->
	<script>
		// let str = '<span style="color: red;">我</span>爱中国'
		// document.body.innerHTML = str

		//--------------------
		// let str2 = '<span style="color: red;">A</span>B<span style="color: red;">A</span>P git客户端'
		// document.body.innerHTML = str2
		//----------  replace方法--------------------------
		let str = 'ABAPgit客户端aaaaa'
		// str.replace('字符串中的字符'|| 正则表达式, 要替换成什么字符)  replace会返回替换的结果
		// const res = str.replace('A', '<span style="color: red;">A</span>')
		// console.log(res);
		// document.body.innerHTML = res
		// replace方法参数一可以写正则   g global 全局查找  i 忽略大小写
		const res = str.replace(/a/gi, '<span style="color: red;">A</span>')
		console.log(res);
		document.body.innerHTML = res
	// 以上实现方式有瑕疵
	</script>
</body>

</html>